package com.hnevc.androiduiclassone3;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.control_layout);
        // 1 获取对象
        RadioGroup radioGroup = findViewById(R.id.rg_sex);
        // 2 设置radioGroup对象的点击事件
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                Log.e(TAG, "onCheckedChanged: " +checkedId );
                switch (checkedId){
                    case R.id.rb_male:
                        Log.e(TAG, "onCheckedChanged: "+"男" );
                        break;
                    case R.id.rb_female:
                        Log.e(TAG, "onCheckedChanged: "+"女" );
                        break;
                }
            }
        });
    }

    public void login(View view) {
        Log.e(TAG, "login: " + ((Button) view).getText());
        //跳转
        Intent intent = new Intent();
        intent.setClass(this,CourseActivity.class);
        startActivity(intent);
    }

}
